// importM
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import './MyIcon.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        // 顶部导航
        appBar: AppBar(
          title: Text("Hello Flutter"),
          backgroundColor: Colors.deepPurple,
        ),
        body: Column(
          children: [
            // MyApp(),
            // likeDiv(),
            // myButtom(),
            // MyImg(),
            // circleImg(),
            // ClipImage(),
            // LocalImage(),
            MyIcons(),
          ],
        ),
      ),
    ),
  );
}

// statelessW
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text(
        "Hello Flutter",
        textDirection: TextDirection.ltr,
        style: TextStyle(color: Colors.deepPurple, fontSize: 40.0),
      ),
    );
  }
}

// 容器组件
// ignore: camel_case_types
class likeDiv extends StatelessWidget {
  const likeDiv({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      // 容器组件
      child: Container(
        width: 200,
        height: 200,
        margin: EdgeInsets.all(30),
        // 移动
        // transform: Matrix4.translationValues(20, 0, 0),
        // 旋转
        // transform: Matrix4.rotationZ(5),
        decoration: BoxDecoration(
          // 背景颜色
          color: Colors.deepPurple,
          // 边框
          border: Border.all(
            color: const Color.fromARGB(255, 206, 99, 248),
            width: 5,
          ),
          // 圆角
          borderRadius: BorderRadius.circular(50),
          // 阴影
          boxShadow: const [
            BoxShadow(color: Color.fromARGB(255, 132, 0, 255), blurRadius: 20),
          ],
          // 线性渐变 从左到右
          gradient: LinearGradient(
            colors: [
              const Color.fromARGB(255, 200, 31, 252),
              const Color.fromARGB(255, 108, 24, 253),
            ],
          ),
          // 径向渐变 圆形 从内到外
          // gradient: RadialGradient(
          //   colors: [
          //     const Color.fromARGB(255, 200, 31, 252),
          //     const Color.fromARGB(255, 108, 24, 253),
          //   ],
          // ),
        ),
        // 元素内居中
        alignment: Alignment.center,
        // 文字属性
        child: Text(
          "Hello Flutter",
          style: TextStyle(color: Colors.white, fontSize: 20),
        ),
      ),
    );
  }
}

// ignore: camel_case_types
class myButtom extends StatelessWidget {
  const myButtom({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 250,
        height: 80,
        alignment: Alignment.center,
        // 背景颜色
        decoration: BoxDecoration(
          color: Colors.deepPurple,
          borderRadius: BorderRadius.circular(30),
        ),
        child: Text("按钮", style: TextStyle(color: Colors.white, fontSize: 30)),
      ),
    );
  }
}

// 图片组件
class MyImg extends StatelessWidget {
  const MyImg({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 100,
        height: 100,
        margin: EdgeInsets.all(20),
        decoration: BoxDecoration(
          color: Colors.deepPurpleAccent,
          borderRadius: BorderRadius.circular(10),
        ),
        child: Image.network(
          "https://xiayh.top/upload/thumbnails/2025/w800/DM20250828171248001.png",
          scale: 2,
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}

// 圆形图片
// ignore: camel_case_types
class circleImg extends StatelessWidget {
  const circleImg({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 150,
      height: 150,
      decoration: BoxDecoration(
        color: Colors.pink,
        borderRadius: BorderRadius.circular(75),
        image: DecorationImage(
          image: NetworkImage(
            "https://xiayh.top/upload/thumbnails/2025/w800/DM20250828171248001.png",
          ),
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}

// 使用ClipOva实现图片圆角
class ClipImage extends StatelessWidget {
  const ClipImage({super.key});

  @override
  Widget build(BuildContext context) {
    return ClipOval(
      child: Image.network(
        "https://xiayh.top/upload/thumbnails/2025/w800/DM20250828171248001.png",
        width: 200,
        height: 200,
        fit: BoxFit.cover,
      ),
    );
  }
}

// 加载本地图片
// ignore: use_key_in_widget_constructors
class LocalImage extends StatelessWidget {
  const LocalImage({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 200,
      height: 200,
      decoration: BoxDecoration(color: Colors.blueAccent),
      child: Image.asset("images/a.jpeg", fit: BoxFit.cover),
    );
  }
}

// 图标组件
class MyIcons extends StatelessWidget {
  const MyIcons({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        SizedBox(height: 20),
        Icon(Icons.adobe, size: 60, color: Colors.pinkAccent),
        SizedBox(height: 10),
        Icon(
          CupertinoIcons.link_circle_fill,
          size: 60,
          color: Colors.blueAccent,
        ),
        SizedBox(height: 10),
        Icon(Icons.bluetooth, size: 60, color: Colors.deepPurpleAccent),
        SizedBox(height: 10),
        Icon(MyIcon.steam, size: 20, color: Colors.deepPurpleAccent),
        SizedBox(height: 10),
        Icon(MyIcon.apex, size: 50, color: Colors.deepPurpleAccent),
        SizedBox(height: 10),
        Icon(MyIcon.warframe, size: 50, color: Colors.deepPurpleAccent),
        SizedBox(height: 10),
        Icon(MyIcon.epic, size: 50, color: Colors.deepPurpleAccent),
        SizedBox(height: 10),
        Icon(MyIcon.github, size: 50, color: Colors.deepPurpleAccent),
        SizedBox(height: 10),
        Icon(MyIcon.gitlab, size: 50, color: Colors.deepPurpleAccent),
      ],
    );
  }
}
